home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10648 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  42 lines

  1. Newsgroups: comp.lang.c
  2. Path: scn.org!kurt
  3. From: kurt@scn.org (Kurt Cockrum)
  4. Subject: Why does the "universal bugfunction" gets() survive in 1996?
  5. Message-ID: <DoDGq8.Dqq@scn.org>
  6. Sender: news@scn.org
  7. Reply-To: kurt@scn.org (Kurt Cockrum)
  8. Organization: Seattle Community Network
  9. Date: Sat, 16 Mar 1996 18:01:20 GMT
  10.  
  11.  
  12. The gets() function reads characters into a buffer until a newline or
  13. EOF is received.  It's dangerous because no length constraints
  14. on the function exists, and the possibility of buffer overruns is
  15. always present.  This is even noted on the man page, where it says
  16. that the fgets() function should be used instead.  See gets(3).
  17. This is all old, well-known stuff.
  18.  
  19. Here's my question to the sages of usenet and this newsgroup:
  20. Why does the function continue to exist?  Why not let it die the
  21. ignominious death it deserves?  Whose code would break by it's
  22. disappearance?  and why *shouldn't* that code break, especially
  23. since it's inherently dangerous and is potentially a grave disservice
  24. to any user?  And it would be nice to know what code that is, so
  25. it could be avoided.
  26.  
  27. And why is there so little discussion of this?  Not even in the "C
  28. Rationale" have I seen any reasoning behind the decision to keep gets().
  29. Not even in P. J. Plauger's voluminous writings (otherwise extremely
  30. enlightening) about the C standardization process has there been any
  31. mention of this (at least to my knowledge).
  32.  
  33. Especially, I'd be interested in hearing why and how this function
  34. snuck it's way into the ANSI standard library...talk about virii!
  35. Kinda makes me think that if I were a darkside cracker, I'd join
  36. some standardization process...I might not catch any old unix hackers,
  37. but there's a whole new crop of Windoze & NT programmers porting their
  38. stuff to unix, just waiting to get bit...
  39. --
  40. -- kurt@scn.org  kurt@grogatch.seaslug.org  (Kurt Cockrum)
  41. Chair, Seattle-King County Save the Stupids Foundation
  42.